﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Engine.Physics;
namespace Engine
{
    public class Component
    {
        public bool IsActive;
        public GameObject gameObject { get; private set; }

        public Vector2 ownPos;
        public Vector2 Position
        {
            get { return gameObject != null ? gameObject.transform.WorldPosition : ownPos; }
            set
            {
                if (gameObject != null)
                    gameObject.transform.WorldPosition = value;
                else
                    ownPos = value;
            }
        }

        public float Rotation
        {
            get { return gameObject.transform.Rotation; }
            set
            {
                gameObject.transform.Rotation = value;
            }
        }

        public Component()
        {

        }

        public virtual void OnAdd(GameObject _gameObject)
        {
            IsActive = true;
            gameObject = _gameObject;
        }

        public virtual void OnRemove()
        {
            
        }

        /// <summary>
        /// In Awake you can safely get references to other Components. Awake is only called once per script
        /// </summary>
        public virtual void Awake()
        {
        }

        /// <summary>
        /// In Start you can safely get references to other GameObjects. Start is only called once per script
        /// </summary>
        public virtual void Start()
        {
        }

        public virtual void Update(GameTime _gameTime)
        {

        }

        public virtual void LateUpdate(GameTime _gameTime)
        {

        }

        public virtual void Draw()
        {

        }

        public virtual void OnCollision(CollisionInfo _info)
        {

        }

    }
}
